home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Unlimited Gap Absorption.c < prev    next >
Encoding:
Text File  |  1995-04-10  |  2.5 KB  |  101 lines  |  [TEXT/KAHL]

  1. // 3/14/93, MD -- changed to use Hoefler Plain
  2.  
  3. #include <Types.h>
  4. #include <QuickDraw.h>
  5. #include <Fonts.h>
  6. #include <Windows.h>
  7. #include <Menus.h>
  8. #include <SegLoad.h>
  9. #include <Memory.h>
  10. #include <Desk.h>
  11.  
  12. #include "graphics routines.h"
  13. #include "graphics libraries.h"
  14. #include "graphics toolbox.h"
  15.  
  16. #include "layout types.h"
  17. #include "layout routines.h"
  18. #include "layout library.h"
  19.  
  20. #include "SampleInterface.h"
  21.  
  22. short MyStrLen(char *x);
  23. static short MyStrLen(x)
  24. char    *x;
  25.     {
  26.     short c = 0;
  27.     while (*x++) c++;
  28.     return c;
  29.     }    /* MyStrLen */
  30.  
  31. void UnlimitedGapAbsorption(WindowPtr sampleWindow)
  32.     {
  33.     /* Variables */
  34.     char                        *myString = "all to space";
  35.     gxGlyphcode                    glyphcodes[30];
  36.     gxGlyphJustificationOverride    glyphJustOverride;
  37.     gxLayoutOptions                gxLayoutOptions;
  38.     gxLine                        myLine;
  39.     gxPoint                        myPoint;
  40.     gxShape                        layout;
  41.     short                        len, level = 0;
  42.     gxStyle                        myStyle;
  43.     unsigned short                firstGlyph, secondGlyph;
  44.     gxViewPort                    aViewPort;
  45.     
  46.     /* Initialization */
  47.     
  48.     myPoint.x = ff(30);
  49.     myPoint.y = ff(50);
  50.     
  51.     aViewPort = GXNewWindowViewPort(sampleWindow);
  52.     SetDefaultViewPort(aViewPort);
  53.     
  54.     len = MyStrLen(myString);
  55.     
  56.     InitializeLayoutOptions(&gxLayoutOptions);
  57.     gxLayoutOptions.width = ff(500);
  58.     gxLayoutOptions.just = 0;
  59.     
  60.     myLine.first.x = myLine.last.x = myPoint.x;
  61.     myLine.first.y = 0;
  62.     myLine.last.y = ff(1000);
  63.     GXDrawLine(&myLine);
  64.     
  65.     myLine.first.x = myLine.last.x = myPoint.x + gxLayoutOptions.width;
  66.     GXDrawLine(&myLine);
  67.     
  68.     myStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  69.     
  70.     layout = GXNewLayout(
  71.         1, &len, (void *) &myString,
  72.         1, &len, &myStyle,
  73.         1, &len, &level,
  74.         &gxLayoutOptions, &myPoint);
  75.     GXDrawShape(layout);
  76.     
  77.     gxLayoutOptions.just = fract1;
  78.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  79.     GXMoveShape(layout, 0, ff(75));
  80.     GXDrawShape(layout);
  81.     
  82.     GXGetLayoutGlyphs(layout, glyphcodes, nil, nil, nil, nil, nil, nil);
  83.     GXGetOffsetGlyphs(layout, 3, false, nil, &firstGlyph, &secondGlyph);
  84.  
  85.     glyphJustOverride.override.beforeGrowLimit = 0;
  86.     glyphJustOverride.override.afterGrowLimit = 0;
  87.     glyphJustOverride.override.beforeShrinkLimit = 0;
  88.     glyphJustOverride.override.afterShrinkLimit = 0;
  89.  
  90.     glyphJustOverride.glyph = glyphcodes[firstGlyph];
  91.     glyphJustOverride.override.growFlags = gxOverrideUnlimited + gxUnlimitedGapAbsorption;
  92.     glyphJustOverride.override.shrinkFlags = 0;
  93.     GXSetStyleRunGlyphJustOverrides(myStyle, 1, &glyphJustOverride);
  94.     GXMoveShape(layout, 0, ff(75));
  95.     GXDrawShape(layout);
  96.     
  97.     GXDisposeShape(layout);
  98.     GXDisposeStyle(myStyle);
  99.     GXDisposeViewPort(aViewPort);
  100.     }    /* main */
  101.